package com.tuyrt.firstcode.common

import android.app.Activity

/**
 * Created by tuyrt7 on 2021/4/6.
 * activity管理
 */
object ActivityCollector {

    private val activities = ArrayList<Activity>()

    fun addActivity(activity: Activity) {
        activities += activity
    }

    fun removeActivity(activity: Activity) {
        activities -= activity
    }

    fun finishAll() {
        activities.forEach { activity ->
            if (!activity.isFinishing) {
                activity.finish()
            }
        }
        activities.clear()
    }
}


